<!-- 定义导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
    <div class="container">
        <!-- 导航栏商标 -->
        <a class="navbar-brand" href="#">博客</a>
        <!-- 导航入口 -->
        <div>
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="/index">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/note/mynote">进入我的博客</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/note/notelist">全站博客列表</a>
                </li>
                <!-- Django的 if 模板语句 -->
                {% if request.session.username %}
                <!-- 如果用户已经登录，则显示用户名下拉框 -->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        {{ request.session.username }}
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="/academy/mysite">个人学术主页</a>
                        <a class="dropdown-item" href="/user/exit">退出登录</a>
                    </div>
                </li>
                <!-- 如果用户未登录，则显示 “登录” -->
                {% else %}
                <li class="nav-item">
                    <a class="nav-link" href="/user/login">登录</a>
                </li>
                <!-- if 语句在这里结束 -->
                {% endif %}
            </ul>
        </div>
    </div>
</nav>


